<template>
  <div class="home">
    <router-view />
    <van-tabbar
      v-model="active"
      :active-color="activeColor"
      class="bottom-bar"
      route
      :class="{'bg-transparent': isTransparent}"
    >
      <van-tabbar-item icon="wap-home-o" to="/">首页</van-tabbar-item>
      <van-tabbar-item icon="like-o" to="/collect">收藏</van-tabbar-item>
      <van-tabbar-item icon="add-o" to="/release">发布</van-tabbar-item>
      <van-tabbar-item icon="apps-o" to="/channel">频道</van-tabbar-item>
      <van-tabbar-item icon="user-circle-o" to="/user">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
    name: 'home',
    data () {
        return {
            active: 0,
            isTransparent: false,
            activeColor: '#07c160'
        }
    },
    created () {
        if (this.$route.path === '/') {
            this.isTransparent = true
            this.activeColor = '#fff'
        }
    },
    watch: {
        '$route' (route) {
            if (route.path === '/') {
                this.isTransparent = true
                this.activeColor = '#fff'
            } else {
                this.isTransparent = false
                this.activeColor = '#07c160'
            }
        }
    }
}
</script>

<style lang="scss" scoped>
  .bottom-bar {
    transition: background-color 0.2s;
  }
  .bg-transparent {
    background-color: transparent;
    border-top: 1PX solid rgba(235, 237, 240, 0.1);
    &:after {
      border: none;
    }
  }
</style>
